package com.googlecode.websecuritychecks;

import java.util.*;

import javax.servlet.http.HttpServletRequest;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class ParameterNameCheck extends RegexBasedCheck {

    @Override
    protected List<String> getValuesToBeChecked(final HttpServletRequest httpServletRequest) {

        List<String> values = new ArrayList<>();
        for (Map.Entry<String, String[]> entry : httpServletRequest.getParameterMap().entrySet()) {
            values.add(entry.getKey());
        }
        return values;
    }

    @Override
    protected NodeList getRuleXmlNodeList(final Element ruleXmlElementFragment) {
        return ruleXmlElementFragment.getElementsByTagNameNS("http://sai.com/websecuritychecks", "InvalidParameterNameCheck");
    }

}
